﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Abp.Auditing;
using Abp.Modules;
using Abp.Rebus.Auditing;
using Abp.Rebus.Core;
using Abp.Rebus.Rabbit;

namespace Abp.Rebus
{
    public class AbpRebusModule : AbpModule
    {
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());

        }

        public override void PostInitialize()
        {

            var configuration = IocManager.Resolve<IRabbitConfiguration>();


            if (configuration.Enable)
            {
                if (!string.IsNullOrEmpty(configuration.QueueName))
                {
                    RebusConfiguration.Start(configuration.RabbitMqConStr, configuration.QueueName);
                }
                else
                {
                    RebusConfiguration.Start(configuration.RabbitMqConStr);
                }

            }

        }


    }
}
